﻿@using System.IO
@using System.Web
@using NewLife.Cube.Web;
@{
    var set = NewLife.Cube.Setting.Current;
    var returnUrl = ViewBag.ReturnUrl as String;
    var ms = NewLife.Web.OAuthConfig.Current.Items.Where(e => !e.AppID.IsNullOrEmpty()).ToList();
    var dic = "NewLife=新生命,Baidu=百度,Weixin=微信,Taobao=淘宝".SplitAsDictionary("=", ",");
}
@if (ms.Count > 0 && set.AutoRegister)
{
    <div class="text-center">
        @*<div class="ui horizontal divider">
            <span style="font-size: 22px;">
                第三方登录
            </span>
        </div>*@
        <div class="col-sm-12">
            <p style="font-size: 22px; position: relative; display: inline-block;width: 100%">
                <span style="height: 1px; position: absolute; background-color: #928f8f; width: 28%; top: 50%; left:65%;"></span>
                第三方登录
                <span style="height: 1px; position: absolute; background-color: #928f8f; width: 28%; top: 50%; right:65%;"></span>
            </p>
        </div>
        <div class="row" style="padding: 0 0 0 0;">
            <div class="form-group col-sm-12">
                @foreach (var mi in ms)
                {
                    var nickName = "";
                    if (!dic.TryGetValue(mi.Name, out nickName))
                    {
                        nickName = mi.Name;
                    }

                    var url = "Sso/Login?name=" + mi.Name;
                    if (!returnUrl.IsNullOrEmpty())
                    {
                        url += "&r=" + HttpUtility.UrlEncode(returnUrl);
                    }

                    url =
                        //HttpRuntime.AppDomainAppVirtualPath
                        "/"+ url;
                    var ico = "/Content/images/logo/{0}.png".F(mi.Name);
                    var ico2 = ico.TrimStart("/").GetFullPath();

                    <a href="@url">
                        @if (File.Exists(ico2))
                        {
                            <text><img src="@ico" title="@nickName" /></text>
                        }
                        else
                        {
                            <i class="glyphicon glyphicon-menu-right"></i>
                            <text>@nickName</text>
                        }
                    </a>
                }
            </div>
        </div>
    </div>
}